package com.example.test.启动线程;

public class Runable2 {

    public static void main(String[] args) {

        class MyThread implements Runnable {
            @Override
            public void run() {
                while (true) {
//                    Thread thread = Thread.currentThread();
//                    if (thread.isInterrupted()) {
//                        break;
//                    }
//                    if (Thread.interrupted()) {
//                        break;
//                    }
//                    System.out.println(thread.isInterrupted());
                    System.out.println(Thread.interrupted());

                }
            }
        }


        MyThread myThread = new MyThread();
        Thread thread = new Thread(myThread);
        thread.start();

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        thread.interrupt();//标记中断

    }


}
